﻿using AdminModels;
using CoinControllers;
using CoinModels;
using Common;
using DataPool;
using DataPool.Tickers;
using Entities;
using Entities.Admin;
using Entities.CoinEntities;
using Entities.CoinEntities.BTCe;
using Entities.CoinEntities.Cryptsy;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using NUnit.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Net.Http.Formatting;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;

namespace Tests
{
    [TestFixture]
    public class Class1
    {
        [TestFixtureSetUp]
        public void TestInitialize()
        { }

        [TestFixtureTearDown]
        public void TestCleanup()
        { }

        [Test]
        public void APITest()
        {
            Assert.IsTrue(BTCeDataCollector.CollectData().Count > 0);
        }

        [Test]
        public void CryptsyAPITest()
        {
            Assert.IsTrue(CryptsyDataCollector.CollectData().Count > 0);
        }

        [Test]
        public void ErrorLogTest()
        {
            Assert.IsTrue(ErrorLog.SaveLog(new Exception("Test")));
        }

        [Test]
        public void TestSettings()
        {
            int answer = 0;
            answer = Settings.GetSetting("MaxTickerCollectAttempts", 0);
            Assert.AreEqual(5, answer);
        }

        [Test]
        public void TestPoolCoinMarket()
        {
            PoolCoin temp = new PoolCoin();

            Assert.IsTrue(temp.AddMarket(Enums.Markets.BTCe));
            Assert.IsTrue(temp.Markets.MarketData.Contains(Enums.Markets.BTCe));
            Assert.IsFalse(temp.AddMarket(Enums.Markets.BTCe));
        }

        [Test]
        public void TickerDataPoolerTest()
        {
            Assert.IsTrue(CoinDataPooler.PoolCoins());
        }

        [Test]
        public void ManualCacheTest()
        {
            CacheController cache = new CacheController();
            cache.UpdateCache(true);
            int baseCount = cache.CryptsyCoins.Count;
            Assert.IsTrue(baseCount > 200);
            Assert.AreEqual(2, cache.BTCeCoins.Count);
            Assert.AreEqual(baseCount + 2, cache.PoolCoins.Count);
        }

        [Test]
        public void TestTest()
        {
            Assert.IsTrue(true);
        }
    }
}
